package com.lkc.handler.exception;

import com.lkc.domain.ResponseResult;
import com.lkc.exception.SystemException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {

    @ExceptionHandler(SystemException.class)
    public ResponseResult systemExceptionHandler(SystemException e) {
        //打印错误日志
        log.error("出现了异常: {}", e);
        //封装错误信息返回
        return ResponseResult.okResult(e.getCode(), e.getMsg());
    }
}
